﻿using Corina.DataContext.Master;
using Corina.Datamodel.DataObject;
using Corina.Datamodel.Entities;
using Corina.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Corina.Webservice.Cydee
{
    /// <summary>
    /// Summary description for User
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class User : WebserviceBase
    {

        [WebMethod]
        public ResultInfo GetPendingUser(string account, string password)
        {
            return GetInstance<UserMaster>().GetPendingUser(account, password);
        }

        [WebMethod]
        public ResultInfo UpdateUserStatus(string account, string password, int userId, AccountStatusValue status)
        {
            return GetInstance<UserMaster>().UpdateUserStatus(account, password, userId, status);
        }

        [WebMethod]
        public ResultInfo RemoveUser(string account, string password, int userId)
        {
            UserInfo entity = new UserInfo() { Id = userId };
            return GetInstance<UserMaster>().Update(account, password, entity, EntityOperation.Delete);
        }

        [WebMethod]
        public ResultInfo GetAllUserItems(string account, string password, string key, int index, int size)
        {
            return GetInstance<UserMaster>().GetAllItems(account, password, key, index, size);
        }

        [WebMethod]
        public ResultInfo ChangeUserLevel(string account, string password, int userId, int levelId)
        {
            return GetInstance<UserMaster>().ChangeUserLevel(account, password, userId, levelId);
        }

        [WebMethod]
        public ResultInfo GetUserInfo(string account, string password, int userId)
        {
            return GetInstance<UserMaster>().GetUserInfo(account, password, userId);
        }

        [WebMethod]
        public ResultInfo GetHypotaxis(string account, string password, int superiorId, int index, int size)
        {
            return GetInstance<UserHypotaxisMaster>().GetSubusers(account, password, superiorId, index, size);
        }

        [WebMethod]
        public ResultInfo UpdateHypotaxis(string account, string password, int superiorId, string subids)
        {
            return GetInstance<UserHypotaxisMaster>().Update(account, password, superiorId, subids);
        }

        [WebMethod]
        public ResultInfo GetUnallocateUsers(string account, string password, string key, int index, int size)
        {
            return GetInstance<UserHypotaxisMaster>().GetUnallocateUsers(account, password, key, index, size);
        }
    }
}
